package com.xl98.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.xl98.entity.Groups;
import com.xl98.entity.MsgContent;
import com.xl98.mapper.MsgContentMapper;
import com.xl98.service.MsgContentService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author ls
 * @since 2020-05-15
 */
@Service
public class MsgContentServiceImpl extends ServiceImpl<MsgContentMapper, MsgContent> implements MsgContentService {
    @Autowired
    private MsgContentMapper msgContentMapper;

    @Override
    public boolean insert(MsgContent msgContent) {
        if(msgContentMapper.insert(msgContent)>0){
            return true;
        }
        return false;
    }

    @Override
    public MsgContent selectById(String id) {
        MsgContent msgContent = msgContentMapper.selectById(id);
        return msgContent;
    }

    @Override
    public boolean deleteById(String id) {
        if(msgContentMapper.deleteById(id)>0){
            return true;
        }
        return false;
    }

    @Override
    public List<MsgContent> selectByUserId(String userId) {
        QueryWrapper<MsgContent> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("user_id",userId);
        List<MsgContent> list = msgContentMapper.selectList(queryWrapper);
        return list;
    }
}
